package com.rem.designPattern.facade外观;

/**
 * 外观模式
 * 为子系统中的一组接口提供一个一致的界面，Facade模式定义了一个高层接口，这个接口使得这一子系统更加容易使用
 * <p>
 * 家庭影院类
 *
 * @author Rem
 * @date 2022-11-17
 */
public class HomeTheaterFacade {
    private final TheaterLights lights;
    private final Screen screen;
    private final Projector projector;
    private final Stereo stereo;
    private final DVDPlayer player;

    public HomeTheaterFacade() {
        this.lights = TheaterLights.getInstance();
        this.screen = Screen.getInstance();
        this.projector = Projector.getInstance();
        this.stereo = Stereo.getInstance();
        this.player = DVDPlayer.getInstance();
    }

    public void ready() {
        lights.off();
        screen.down();
        projector.on();
        stereo.on();
        player.on();
    }

    public void play() {
        player.play();
    }

    public void pause() {
        player.pause();
    }

    public void end() {
        lights.on();
        player.off();
        projector.off();
        stereo.off();
        screen.up();
    }
}